<template>
<pk-dialog :footer="false" v-if="linkShow" @onClose="onClose" style="width: 300px;">
  <div class="flex-column align-items-center justify-center page-wrap-link">
    <div class="page-wrap-linkpath">
      <pk-canvas :modelValue="linkPath">
        <div>
          微信扫一扫，开始对话
        </div>
      </pk-canvas>
    </div> 
  </div>
</pk-dialog>
</template>

<script setup>
import { agentGetList, generateChatLink, generateSession } from '@/api/api'
import pkDialog from '@/components/pkui/pkdialog/pkdialog.vue'
import pkCanvas from '@/components/pkui/pkcanvas/pkcanvas.vue'
import { defineProps, ref, onMounted, defineEmits } from 'vue'
const emits = defineEmits(['onClose'])
const linkPath = ref("")
const props = defineProps({
  data: {
    type:Object,
    default: () => {}
  },
  scene: {
    type:String,
    default: "B"
  },
  channelId: {
    type:String,
    default: ""
  }
})
const linkShow = ref(true)

// const getLink  = () => {
//   generateChatLink({
//     agent_id: props.data.agent_id,
//     is_public: 1
//   }).then(res => {
//     linkPath.value = res.data
//   })
// }


const getLink  = () => {
  generateSession({
    scene: props.scene,
    channel_id: props.channelId
  }).then(res => {
    linkPath.value = res.data
  })
}

const onClose = () => {
  emits('onClose')
}
onMounted(() => {
  getLink()
})
</script>

<style lang="scss" scoped>

</style>